Skip to content

feat(ci): bundle-size budget gate (warn-only until baseline enforced)#608

Merged
BigSimmo merged 2 commits into
mainfrom
claude/bundle-budget
Jul 13, 2026
Merged

feat(ci): bundle-size budget gate (warn-only until baseline enforced)#608
BigSimmo merged 2 commits into
mainfrom
claude/bundle-budget

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What

First Tier D item. Protects the repo's perf/bundle-hygiene work from silent regression — a heavy new dependency, or an accidental client-side import of a big module (the "snapshot imported client-side" mistake flagged as a never-do).

  • scripts/check-bundle-budget.mjs — measures .next client chunk sizes (raw + gzip), compares total gzip to a committed baseline with a tolerance; --update records the baseline; skips cleanly when there's no build output. Pure measureChunks/compareToBudget are exported and unit-tested.
  • bundle-budget.json — ships enforce:false, totalGzipBytes:nullWARN-ONLY. It never blocks a PR until you capture a baseline and opt in.
  • ci.yml — a warn-only "Bundle budget" step after Build (cannot fail a run yet).

Rollout (operator, when ready)

  1. After a known-good npm run build: npm run check:bundle-budget -- --update to record the baseline gzip size.
  2. Set "enforce": true in bundle-budget.json (and tune tolerancePct, default 10%).
  3. CI now fails on >tolerance growth; refresh intentionally with --update.

Verification

6/6 vitest (measure + compare logic), no-build smoke (skips), check:github-actions, eslint, tsc (own files clean), prettier — all green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated monitoring of client JavaScript bundle sizes.
    • Bundle-size checks report gzip totals, largest chunks, and changes against a configurable baseline.
    • Added options to update the baseline or output structured results.
  • Bug Fixes

    • CI now detects bundle-size growth and warns when configured limits are exceeded.
  • Tests

    • Added coverage for bundle measurement, tolerance handling, enforcement, and warning behavior.

Tier D. Protects the repo's perf/bundle-hygiene work from silent regression (a
heavy dep, or an accidental client-side import of a big module).

- scripts/check-bundle-budget.mjs: measures .next client chunk sizes (raw + gzip),
  compares total gzip to a committed baseline with a tolerance; `--update` records
  the baseline; skips cleanly when no build output exists. Pure measure/compare
  logic is exported and unit-tested.
- bundle-budget.json: ships enforce:false, totalGzipBytes:null — WARN-ONLY, so it
  never blocks a PR until an operator captures a baseline (`--update` after a
  known-good build) and flips enforce:true.
- ci.yml: warn-only "Bundle budget" step after Build (can't fail a run yet).

Verified: 6/6 vitest, no-build smoke, check:github-actions, eslint, tsc (own files
clean), prettier — all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@supabase

supabase Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 44bddbcf-b0a9-49af-b68d-1805091a895e

📥 Commits

Reviewing files that changed from the base of the PR and between 5098fe3 and a9d09ad.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • bundle-budget.json
  • package.json
  • scripts/check-bundle-budget.mjs
  • scripts/ci-change-scope.mjs
  • tests/bundle-budget.test.ts

📝 Walkthrough

Walkthrough

Adds a warn-only client JavaScript bundle budget checker that measures Next.js chunk sizes, compares them with a configurable baseline, exposes an npm command, runs in CI, and includes unit and scope-classifier tests.

Changes

Bundle budget enforcement

Layer / File(s) Summary
Bundle measurement and budget comparison
bundle-budget.json, scripts/check-bundle-budget.mjs
Measures raw and gzip sizes for built JavaScript chunks, compares totals against tolerance and enforcement settings, supports baseline updates and JSON output, and reports exit statuses.
Budget behavior validation
tests/bundle-budget.test.ts
Tests chunk aggregation, gzip ranking, missing baselines, tolerance boundaries, and warn-versus-fail enforcement.
CI command and change-scope integration
package.json, .github/workflows/ci.yml, scripts/ci-change-scope.mjs
Registers and runs the checker in the build job and classifies its configuration and implementation files as build-scope changes with self-test coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant NpmScript
  participant BundleBudgetChecker
  participant BuildOutput
  participant BudgetConfig
  CI->>NpmScript: run check:bundle-budget
  NpmScript->>BundleBudgetChecker: invoke CLI
  BundleBudgetChecker->>BuildOutput: measure JavaScript chunk sizes
  BundleBudgetChecker->>BudgetConfig: load baseline and tolerance
  BundleBudgetChecker-->>CI: emit verdict and exit code
Loading

Possibly related PRs

  • BigSimmo/Database#454: Introduces the CI change-scope classifier that this change extends for bundle-budget files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/bundle-budget

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 13, 2026 15:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0eb6bb6020

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
@github-actions

Copy link
Copy Markdown

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@BigSimmo
BigSimmo merged commit d7879d9 into main Jul 13, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the claude/bundle-budget branch July 14, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant